﻿//-----------------------------------------------------------------------
// <copyright file="IBusinessManager.cs" company="FastNET Services">
//     Copyright (c) 2007-2013. All Rights Reserved.
// </copyright>
// <warranty>
//     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
//     BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
//     NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
//     DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
//     OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// </warranty>
//-----------------------------------------------------------------------
#region Usings

using System;
using System.Collections.Generic;
using FastNet.BusinessSystem.Exceptions;

#endregion

namespace FastNet.BusinessSystem.Interfaces
{
    /// <summary>
    /// Base interface for all business object managers
    /// </summary>
    public interface IBusinessManager
    {
        /// <summary>
        /// Marks all business objects of <see cref="IBusinessManager"/> as deleted from the data store
        /// </summary>
        /// <exception cref="BusinessDeleteException">Thrown if there was an exception during deletion. Look at the InnerException for detail.</exception>
        void DeleteAll();
    }

    /// <summary>
    /// Management interface for a business
    /// </summary>
    /// <typeparam name="TBusiness">Type of IBusiness this interface manages</typeparam>
    interface IBusinessManager<TBusiness> : IBusinessManager
        where TBusiness : IBusinessObject
    {
        /// <summary>
        /// Retrieves all the business objects for <typeparamref name="TBusiness"/> from the store
        /// </summary>
        /// <returns>List of all objects for <typeparamref name="TBusiness"/></returns>
        /// <exception cref="BusinessRetrieveException">Thrown if there was an exception during retrieving. Look at the InnerException for detail.</exception>
        IList<TBusiness> Retrieve();

        /// <summary>
        /// Deletes the specified list of <typeparamref name="TBusiness"/> from the store
        /// </summary>
        /// <param name="objects">List of all the <typeparamref name="TBusiness"/> to delete</param>
        /// <exception cref="ArgumentNullException">Thrown if objects is null</exception>
        /// <exception cref="BusinessDeleteException">Thrown if there was an exception during deletion. Look at the InnerException for detail.</exception>
        void Delete(IEnumerable<TBusiness> objects);

        /// <summary>
        /// Creates a new instance of the <typeparamref name="TBusiness"/>
        /// </summary>
        /// <returns><typeparamref name="TBusiness"/> created</returns>
        /// <exception cref="BusinessInitializationException">Thrown if there was an issue creating a new business object</exception>
        TBusiness Create();
    }
}